﻿using System;
using System.IO;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Schema;

namespace XmlSchemaVerifier
{
	public static class Core
	{
		/*
		Throws 'XmlSchemaValidationException' on failure
		*/
		public static void Verify(string xmlFilePath, string xsd, XsdType xsdType)
		{
			XmlSchemaSet schemas = new XmlSchemaSet();

			if (xsdType == XsdType.File)
				schemas.Add(String.Empty, xsd);
			else if (xsdType == XsdType.String)
				schemas.Add(String.Empty, XmlReader.Create(new StringReader(xsd)));
			else
				throw new ArgumentException();

			XDocument doc = XDocument.Load(xmlFilePath);
			doc.Validate(schemas, null);
		}
	}
}
